package com.mit.web.business.remote
{
	import flash.events.EventDispatcher;
	
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.remoting.RemoteObject;
	
	public class RemoteObjectInvoker extends EventDispatcher implements IInvoker
	{
		private var ro:RemoteObject;
		private var defaultFaultHandler:Function;
		public function RemoteObjectInvoker(dest:String)
		{
			ro = new RemoteObject(dest);	
		}
		
		public function invoke(method:String, args:Array):IInvokeResponder
		{
			var operation:AbstractOperation = ro.getOperation(method);
			var token:AsyncToken = operation.send.apply(operation, args);
			return new com.mit.web.business.remote.AsyncResponder(token, defaultFaultHandler);
			
		}
	}
}